/**
 * 
 */
package com.jbat.gwt.tiledmapcreator.client;

import com.jbat.gwt.tiledmapcreator.client.activities.EditMapActivityMapper;
import com.jbat.gwt.tiledmapcreator.client.activities.TileSetActivityMapper;
import com.jbat.gwt.tiledmapcreator.client.places.AppPlaceHistoryMapper;
import com.jbat.gwt.tiledmapcreator.client.places.PlaceControllerProvider;
import com.jbat.gwt.tiledmapcreator.client.places.PlaceHistoryHandlerProvider;
import com.jbat.gwt.tiledmapcreator.client.views.DesignView;
import com.jbat.gwt.tiledmapcreator.client.views.EditMapView;
import com.jbat.gwt.tiledmapcreator.client.views.EditMapViewImpl;
import com.jbat.gwt.tiledmapcreator.client.views.TileSetView;
import com.jbat.gwt.tiledmapcreator.client.views.TileSetViewImpl;

import com.google.gwt.inject.client.AbstractGinModule;
import com.google.gwt.inject.client.assistedinject.GinFactoryModuleBuilder;
import com.google.gwt.place.shared.PlaceController;
import com.google.gwt.place.shared.PlaceHistoryHandler;
import com.google.gwt.place.shared.PlaceHistoryMapper;
import com.google.inject.Singleton;
import com.google.web.bindery.event.shared.EventBus;
import com.google.web.bindery.event.shared.SimpleEventBus;

/**
 * 
 */
public class MapGinModule extends AbstractGinModule {

  /*
   * (non-Javadoc)
   * 
   * @see com.google.gwt.inject.client.AbstractGinModule#configure()
   */
  @Override
  protected void configure() {
    // bindings for dependency injection with GIN
    bind(EventBus.class).to(SimpleEventBus.class).in(Singleton.class);
    bind(PlaceController.class).toProvider(PlaceControllerProvider.class).in(Singleton.class);
    bind(PlaceHistoryMapper.class).to(AppPlaceHistoryMapper.class).in(Singleton.class);
    bind(PlaceHistoryHandler.class).toProvider(PlaceHistoryHandlerProvider.class).in(
        Singleton.class);
    bind(DesignView.class);
    bind(TileSetView.class).to(TileSetViewImpl.class);
    bind(EditMapView.class).to(EditMapViewImpl.class);
    
    // use factories to generate activities from places
    install(new GinFactoryModuleBuilder().build(EditMapActivityMapper.Factory.class));
    install(new GinFactoryModuleBuilder().build(TileSetActivityMapper.Factory.class));
  }
}
